package com.ding.eduservice.controller;


import com.ding.commonutils.Result;
import com.ding.eduservice.entity.subject.Onesubject;
import com.ding.eduservice.service.EduSubjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * <p>
 * 课程科目 前端控制器
 * </p>
 *
 * @author testjava
 * @since 2020-11-14
 */
@RestController
@RequestMapping("/eduservice/subject")
@CrossOrigin
public class EduSubjectController {
   @Autowired
    private EduSubjectService eduSubjectService;

   //添加课程分类
    //获取上传过来文件，把文件内容读取出来
    @PostMapping("addSubject")
    public Result addSubject(MultipartFile file){
        //上传过来的excel文件
        eduSubjectService.saveSubject(file,eduSubjectService);
        return  Result.ok();
    }

    //显示课程数据(树形)
    @GetMapping("getSubject")
    public Result getSubject(){
        //list泛型是一级分类
        List<Onesubject> list = eduSubjectService.getSubject();
        return Result.ok().data("list",list);
    }
}

